home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50a Issue 142 (CD142a) (August 1998).iso / trial / demon / TURNPIKE.1 / CLASSES.ZIP / JAVA / AWT / Font.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-04-14  |  2.4 KB  |  113 lines

  1. package java.awt;
  2.  
  3. public class Font {
  4.    public static final int PLAIN = 0;
  5.    public static final int BOLD = 1;
  6.    public static final int ITALIC = 2;
  7.    private int pData;
  8.    private String family;
  9.    protected String name;
  10.    protected int style;
  11.    protected int size;
  12.  
  13.    public Font(String var1, int var2, int var3) {
  14.       this.family = System.getProperty("awt.font." + var1.toLowerCase(), var1);
  15.       this.name = var1;
  16.       this.style = var2;
  17.       this.size = var3;
  18.    }
  19.  
  20.    public String getFamily() {
  21.       return this.family;
  22.    }
  23.  
  24.    public String getName() {
  25.       return this.name;
  26.    }
  27.  
  28.    public int getStyle() {
  29.       return this.style;
  30.    }
  31.  
  32.    public int getSize() {
  33.       return this.size;
  34.    }
  35.  
  36.    public boolean isPlain() {
  37.       return this.style == 0;
  38.    }
  39.  
  40.    public boolean isBold() {
  41.       return (this.style & 1) != 0;
  42.    }
  43.  
  44.    public boolean isItalic() {
  45.       return (this.style & 2) != 0;
  46.    }
  47.  
  48.    public static Font getFont(String var0) {
  49.       return getFont(var0, (Font)null);
  50.    }
  51.  
  52.    public static Font getFont(String var0, Font var1) {
  53.       String var2 = System.getProperty(var0);
  54.       if (var2 == null) {
  55.          return var1;
  56.       } else {
  57.          String var3 = var2;
  58.          int var4 = 12;
  59.          byte var5 = 0;
  60.          int var6 = var2.indexOf(45, 0);
  61.          if (var6 >= 0) {
  62.             var3 = var2.substring(0, var6);
  63.             int var7 = var6 + 1;
  64.             var2 = var2.substring(var7, var2.count);
  65.             if ((var6 = var2.indexOf(45, 0)) >= 0) {
  66.                if (var2.startsWith("bold-", 0)) {
  67.                   var5 = 1;
  68.                } else if (var2.startsWith("italic-", 0)) {
  69.                   var5 = 2;
  70.                } else if (var2.startsWith("bolditalic-", 0)) {
  71.                   var5 = 3;
  72.                }
  73.  
  74.                var7 = var6 + 1;
  75.                var2 = var2.substring(var7, var2.count);
  76.             }
  77.  
  78.             try {
  79.                Integer var12 = new Integer(Integer.parseInt(var2, 10));
  80.                var4 = var12.value;
  81.             } catch (NumberFormatException var8) {
  82.             }
  83.          }
  84.  
  85.          return new Font(var3, var5, var4);
  86.       }
  87.    }
  88.  
  89.    public int hashCode() {
  90.       return this.name.hashCode() ^ this.style ^ this.size;
  91.    }
  92.  
  93.    public boolean equals(Object var1) {
  94.       if (var1 instanceof Font) {
  95.          Font var2 = (Font)var1;
  96.          return this.size == var2.size && this.style == var2.style && this.name.equals(var2.name);
  97.       } else {
  98.          return false;
  99.       }
  100.    }
  101.  
  102.    public String toString() {
  103.       String var1;
  104.       if (this.isBold()) {
  105.          var1 = this.isItalic() ? "bolditalic" : "bold";
  106.       } else {
  107.          var1 = this.isItalic() ? "italic" : "plain";
  108.       }
  109.  
  110.       return this.getClass().getName() + "[family=" + this.family + ",name=" + this.name + ",style=" + var1 + ",size=" + this.size + "]";
  111.    }
  112. }
  113.